package com.example.demo.service.impl;

import com.example.demo.domain.Girl;
import com.example.demo.repository.GirlRepository;
import com.example.demo.service.GirlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class GirlServiceImpl implements GirlService{
  @Autowired
  private GirlRepository girlRepository;


  @Override
  public List<Girl> getAll() {
    List<Girl> girlList = girlRepository.findAll();
    return girlList;
  }


  @Override
  public Girl getOneById(Integer id) {
    Girl girl = girlRepository.findOne( id );
    return girl;
  }

  /**
   * @param girl
   * @Description 保存用户信息
   * @Author 王盼
   * @Date 2018/11/19 20:27
   * @method
   */
  @Override
  public Object save(Girl girl) {
    Girl res = girlRepository.save( girl );
    return res;
  }

  /**
   * @param id
   * @Description 根据用户Id删除用户
   * @Author 王盼
   * @Date 2018/11/19 20:26
   * @method
   */
  @Override
  public void deleteGirlById(Integer id) {
    girlRepository.delete( id );
  }

  /**
   * @param age
   * @Description 根据年龄查询女生信息
   * @Author 王盼
   * @Date 2018/11/19 20:25
   * @method
   */
  @Override
  public List<Girl> getGirlListByAge(Integer age) {
   List<Girl> list = girlRepository.findGirlListByAge(age);
    return list;
  }
}